package Aula12;

public class Peca implements Comparable<Peca>{

	private int num1;
	private int num2;

	public Peca(int num1, int num2) {
		this.num1 = num1;
		this.num2 = num2;
	}

	public int getNum1() {
		return num1;
	}

	public int getNum2() {
		return num2;
	}
	
	public void inverter(){
		int aux = num1;
		num1 = num2;
		num2 = aux;
	}

	public boolean containNumber(int n) {
		return (num1 == n || num2 == n);
	}
	
	public int getValor(){
		return num1 + num2;
	}
	
	public boolean equals(Object obj) {
		if (obj instanceof Peca) {
			return ((((Peca) obj).getNum1() == num1 && ((Peca) obj).getNum2() == num2) || (((Peca) obj)
					.getNum2() == num1 && ((Peca) obj).getNum1() == num2));
		}
		return false;
	}

	public String toString() {
		return num1 + "|" + num2;
	}

	public int compareTo(Peca arg0) {
		if(getValor() <  arg0.getValor()){
			return -1;
		}
		if(getValor() == arg0.getValor()){
			return 0;
		}
		return 1;
	}

}
